package com.hb.study.design_patterns.chain_of_responsibility;

import org.junit.Test;

/**
 * 测试
 *
 * @author Mr.Huang
 * @version v0.1, MainTest.java, 2020/6/16 11:05, create by huangbiao.
 */
public class MainTest {

    /**
     * 固定顺序执行
     */
    @Test
    public void test1() {
        AbstractChain chainOne = new ChainOne(1);
        AbstractChain chainTwo = new ChainTwo(2);
        AbstractChain chainThree = new ChainThree(3);

        chainOne.setChain(chainTwo);
        chainTwo.setChain(chainThree);
        chainThree.setChain(NullChain.build(4));

        chainOne.doChain();
    }

    /**
     * 通过step来依次执行
     */
    @Test
    public void test2() {
        AbstractChain chainOne = new ChainOne(1);
        AbstractChain chainTwo = new ChainTwo(2);
        AbstractChain chainThree = new ChainThree(3);
        NullChain nullChain = NullChain.build(4);

        AbstractChain.doChainByStep(chainOne,chainThree,nullChain,chainTwo);
    }

}

    